<template>
  <el-form label-position="left" label-width="40px" size="mini">
    <el-form-item label="封面">
      <imageUpload :image-props="resource.cover" @success="successHandler" />
    </el-form-item>
    <el-form-item label="标题">
      <el-input clearable type="text" v-model="resource.name" />
    </el-form-item>
    <el-form-item label="作者">
      <el-input clearable type="text" v-model="resource.artist" />
    </el-form-item>
    <el-form-item label="简介">
      <el-input :autosize="{minRows: 2, maxRows: 6}" resize="none" type="textarea" v-model="resource.mark" />
    </el-form-item>
    <el-form-item label="台词">
      <el-input :autosize="{minRows: 5, maxRows: 6}" resize="none" type="textarea" v-model="resource.lyric" />
    </el-form-item>
    <el-form-item>
      <el-button @click="$emit('commit')" class="btn" type="primary">确定</el-button>
      <el-button @click="$emit('cancel')" class="btn" type="text">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import imageUpload from '@/components/imageUpload/index.vue';

export default {
    components: {
        imageUpload,
    },
    props: {
        resource: {
            type: Object,
            required: true,
        },
    },
    methods: {
        successHandler(res) {
            this.resource.cover = res.file_path;
            this.$emit('update');
        },
    },
};
</script>

<style lang="scss" scoped>
.btn {
  float: right;
  margin-right: 10px;
}
</style>
